package com.gklyj.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gklyj.pojo.Position;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface positionMapper extends BaseMapper<Position> {

    //信息查询
    List<Position> SearchPositions(Position position);

    //管理员查看招聘单位发布的岗位信息
    @Select("select * from position where name != 'admin'")
    List<Position> ListPositionsExcludeAdmin();

    //管理员查询招聘单位
    List<Position> ZpSearchPositions(Position position);

    //管理员查询招聘单位
    List<Position> AdSearchPositions(Position position);

    //招聘单位更根据条件查询自己单位的岗位信息
    List<Position> thisZpGangweiSearchs(Position position);

    //管理员查看自己发布的岗位信息
    @Select("select * from position where name = 'admin'")
    List<Position> ListPositionsAdmin();

    //不同招聘单位，登陆后列出对应的岗位信息
    @Select("select * from position where department = #{department}")
    List<Position> ListThisGangwei(String department);

    //统计各月的岗位数量
//    @Select("select count(time) from position where time like '%-'+${grade}+'-%'")
    Integer getGwNumberByTime(String time);

    //求所有岗位数量
    @Select("select count(*) from position")
    Integer getGangweiNumber();

    //求某天岗位数量
    @Select("select count(*) from position where time = #{time}")
    Integer getOneDayGangweiNumber(String time);

    //根据条件查一条职位信息
    @Select("select * from position where department=#{department} and p_title=#{p_title}")
    Position findOnePosition(String department,String p_title);

    //根据条件查一条职位信息
    @Select("select * from position where department=#{department} and p_title=#{p_title} and name=#{name}")
    Position findOnePosition1(String department,String p_title,String name);

    //职位已选人数加一
    @Update("update position set quantity = quantity+1 where department=#{department} and p_title=#{p_title}")
    boolean addPositionQuantity(String department,String p_title);

    //职位已选人数减一
    @Update("update position set quantity = quantity-1 where department=#{department} and p_title=#{p_title}")
    boolean reducePositionQuantity(String department,String p_title);
}
